package game.view.panel.game
{
	import com.base.type.LayerEnum;
	import com.greensock.*;
	import com.greensock.easing.*;
	import com.utils.ZooLog;
	
	import flash.display.*;
	import flash.events.*;
	import flash.net.*;
	import flash.utils.*;
	
	import game.model.GameData;
	import game.model.type.Enum;
	import game.view.base.gamepanel.UIbtnViewUI;
	
	import morn.App;
	import morn.core.components.*;
	import morn.core.handlers.Handler;
	public class UIbtnView extends UIbtnViewUI
	{
		private var myLevelId:int=GameData.instance.myLevelId;
		private var lightXyList:Array=[{x:-25,y:-24},{x:100,y:-24},{x:225,y:-24},{x:350,y:-24},{x:475,y:-24},{x:600,y:-24}];
		
		public function UIbtnView()
		{
			super();
		}
		override protected function initialize():void
		{
			super.initialize();
			whyBtn.addEventListener(MouseEvent.CLICK,whyBtnClick);
			jumpBtn.addEventListener(MouseEvent.CLICK,jumpBtnClick);
			recdBtn.addEventListener(MouseEvent.CLICK,recdBtnClick);
			jumpBtn.setLabel('向前跳跃','');
			gaillabel1.text=gaillabel2.text=gaillabel3.text=gaillabel4.text=gaillabel5.text=gaillabel6.text='';
			
			levelTxtBtn1.addEventListener(MouseEvent.CLICK,levelTxtBtnClick);
			levelTxtBtn2.addEventListener(MouseEvent.CLICK,levelTxtBtnClick);
			levelTxtBtn3.addEventListener(MouseEvent.CLICK,levelTxtBtnClick);
			levelTxtBtn4.addEventListener(MouseEvent.CLICK,levelTxtBtnClick);
			levelTxtBtn5.addEventListener(MouseEvent.CLICK,levelTxtBtnClick);
			levelTxtBtn6.addEventListener(MouseEvent.CLICK,levelTxtBtnClick);
		}
		/**
		 * 设置关卡 1-6
		 */
		public function setLevel(levelid:int=Enum.no_num):void{
			if(levelid==Enum.no_num)levelid=GameData.instance.myLevelId;
			var level:int=levelid-1;
			var vo:Object=lightXyList[level];
			levelImg.x=vo.x;
			jumpBtn.setLabel('向前跳跃','消耗'+GameData.instance.playMoney+'呱元');
			var list:Array=GameData.instance.levelList;
			for(var i:int=0;i<list.length;i++){
				var livo:Object=list[i];
				if(livo.awardId==Enum.no_num){
					this['gaillabel'+(i+1)].text='';
				}else{
					this['gaillabel'+(i+1)].text=(livo.succRatio+'%成功');
				}
			}
		}
		private function whyBtnClick(e:MouseEvent):void{
			view.ExplainBtnClick();
		}
		private function jumpBtnClick(e:MouseEvent):void{
			view.jumBtnClick();
		}
		private function recdBtnClick(e:MouseEvent):void{
			view.myRecdBtnBtnClick();
		}
		private function levelTxtBtnClick(e:MouseEvent):void{
			trace('UIbtnView levelTxtBtnClick',e.target.name);
			var name:String=e.target.name;
			var index:int=int(name.charAt(name.length-1));
			if(GameData.instance.isLogin && GameData.instance.isToJump && !GameData.instance.isMapMove){
				GameData.instance.lookId=index;
				view.levelGoods.setLevel(GameData.instance.lookId,true);
				
			}
		}
		
		
		private function get view():GamePanel{
			return (this.parent as GamePanel);
		}
	}
}